package com.apollographql.apollo.internal;

import com.apollographql.apollo.api.Operation;
import com.apollographql.apollo.api.internal.ResponseFieldMapper;
import com.apollographql.apollo.api.internal.Utils;
import java.util.concurrent.ConcurrentHashMap;

@Deprecated
public final class ResponseFieldMapperFactory {
    private final ConcurrentHashMap<String, ResponseFieldMapper> pool = new ConcurrentHashMap<>();

    public ResponseFieldMapper create(Operation operation) {
        Utils.checkNotNull(operation, "operation == null");
        String operationId = operation.operationId();
        ResponseFieldMapper mapper = this.pool.get(operationId);
        if (mapper != null) {
            return mapper;
        }
        this.pool.putIfAbsent(operationId, operation.responseFieldMapper());
        return this.pool.get(operationId);
    }
}
